package com.dd.ms.nacos.config.security;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.SecurityFilterChain;

/**
 * @Author liuxianmeng
 * @CreateTime 2025/3/9 15:55
 * @Description SpringSecurity配置
 */
@Configuration
public class SecurityConfig {

    // 取消默认的 HTTP Basic 认证登录页
    @Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        http.httpBasic().disable() // 禁用 HTTP Basic 认证
            .formLogin().disable() // 禁用表单登录
            .csrf().disable() // 禁用 CSRF 保护
            .sessionManagement()
            .sessionCreationPolicy(SessionCreationPolicy.STATELESS); // 无状态会话管理
        return http.build();
    }
}
